﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class admin_reg : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString.Count != 0)
        {
            string username = Request.QueryString["username"];
            string password = Request.QueryString["password"];
            string str = "Data Source=.;Initial Catalog=blog;Persist Security Info=True;User ID=sa;Password=nihao!1";
            using (SqlConnection conn = new SqlConnection(str))//连接数据库
            {
                conn.Open();//打开
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = "insert into UserInfo (name,password) values (@yhm,@mima) ";//查询输入的内容
                    cmd.Parameters.Add(new SqlParameter("yhm", username));//获取
                    cmd.Parameters.Add(new SqlParameter("mima", password));
                    int falg = cmd.ExecuteNonQuery();

                    if (falg == 1)
                    {
                        Response.Write("注册成功");
                        Response.End();
                    }
                    else
                    {
                        Response.Write("<script>alert('注册失败');</script>");
                        Response.End();
                    }
                }

            }
        }
    }
}